<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="vue.js"></script>
</head>
<body>
    <div id="app">
        <p>{{a}}</p>
        <button id="add" @click="add">增加</button>
        <button id="sub" @click="sub">减少</button>
    </div>

    <script>
        const app=Vue.createApp({
            data() {
                return {
                    a:0
                }
            },
            methods: {
                add(){
                    this.a++
                },
                sub(){
                    if(this.a!=0){
                        this.a--
                    }else{
                        alert("不能再减了！！！")
                    }
                }
            },
        }).mount("#app")
    </script>
</body>
</html>